<!DOCTYPE html>
<html lang="en">
	<head>
		<title>账号验证</title>
		<#include "../inc/header.ftl"/>
	</head>

	<body class="no-skin">

		<div class="main-container ace-save-state" id="main-container">

			<div class="main-content">
				<div class="main-content-inner">

					<div class="page-content">
						<div class="row">
                            <div id="grid-main-data" class="col-xs-12">
                                <table id="MainGrid" style="min-height: 500px"></table>
								<div id="toolbar">
                                    <div style="padding:8px">
                                        <a href="#" onclick="javascript:searchInfo()" class="easyui-linkbutton" iconCls="icon-search">查 询</a>
                                        <a href="#" onclick="javascript:sendInfo()" class="easyui-linkbutton" iconCls="icon-redo">主动获取银行</a>
                                        <a href="#" onclick="javascript:bankManage()" class="easyui-linkbutton" iconCls="icon-ok">核查回执</a>
                                    </div>
								</div>
							</div>
						</div><!-- /.row -->
					</div><!-- /.page-content -->
                    <div id="box-add" class="ui-dialog-content hide">
                        <form class="form-horizontal" id="form-add" method="post">
                            <div class="form-group">
                                <label class="control-label col-xs-12 col-sm-4 no-padding-right">区划</label>
                                <div class="col-xs-12 col-sm-8">
									<span class="block input-icon input-icon-right">
										<input type="text" name="cantonid" id="cantonid" class="col-xs-12 easyui-textbox" data-options="required:true" style="width:100%" />
									</span>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="control-label col-xs-12 col-sm-4 no-padding-right">账户账号</label>
                                <div class="col-xs-12 col-sm-8">
                                    <div class="clearfix">
                                        <input type="text" name="accountcode" id="accountcode" class="col-xs-12 easyui-textbox" data-options="required:true" style="width:100%" />
                                    </div>
                                </div>
                            </div>
                        </form>
                    </div><!-- #dialog-confirm -->
                    <div id="box-update" class="ui-dialog-content hide" data-options="minimizable:true,maximizable:true">
                        <form class="form-horizontal" id="form-update" method="post">
                            <div class="form-group">
                                <input type="text" name="bankid" id="bankid" hidden/>
                                <label class="control-label col-xs-12 col-sm-1 no-padding-right">银行名称&nbsp;</label>
                                <div class="col-xs-12 col-sm-3">
                                    <span class="block input-icon input-icon-right">
                                        <input type="text" name="bankname" id="bankname" class="col-xs-12 easyui-textbox" data-options="required:true" style="width:100%"/>
                                    </span>
                                </div>
                                <label class="control-label col-xs-12 col-sm-1 no-padding-right">账户名称&nbsp;</label>
                                <div class="col-xs-12 col-sm-3">
                                    <span class="block input-icon input-icon-right">
                                        <input type="text" name="accountname" id="accountname"  class="col-xs-12 easyui-textbox" data-options="required:true" style="width:100%" />
                                    </span>
                                </div>
                                <label class="control-label col-xs-12 col-sm-1 no-padding-right">账号</label>
                                <div class="col-xs-12 col-sm-3">
                                    <span class="block input-icon input-icon-right">
                                        <input type="text" name="accountcode" id="accountcode" class="col-xs-12 easyui-textbox"  data-options="required:true" style="width:100%"/>
                                    </span>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="control-label col-xs-12 col-sm-1 no-padding-right">联行行号</label>
                                <div class="col-xs-12 col-sm-3">
                                    <span class="block input-icon input-icon-right">
                                        <input type="text" name="banklinenum" id="banklinenum" class="col-xs-12 easyui-textbox" style="width:100%"/>
                                    </span>
                                </div>
                                <label class="control-label col-xs-12 col-sm-1 no-padding-right">回执类型&nbsp;</label>
                                <div class="col-xs-12 col-sm-3">
                                    <span class="block input-icon input-icon-right">
                                         <select name="operate" id="operate" class="easyui-combobox" data-options="required:true" style="width: 60%;">
                                                <option value="1">通过</option>
                                                <option value="2">修改</option>
                                                <option value="3">差错</option>
                                         </select>
                                    </span>
                                </div>
                                <label class="control-label col-xs-12 col-sm-1 no-padding-right">备注</label>
                                <div class="col-xs-12 col-sm-3">
                                    <span class="block input-icon input-icon-right">
                                        <input type="text" name="memo" id="memo"  style="width: 185px"/>
                                    </span>
                                </div>
                            </div>
                        </form>
                    </div><!-- #dialog-confirm -->
                </div>
			</div><!-- /.main-content -->
		</div><!-- /.main-container -->

		<!-- basic scripts -->
		<#include "../inc/basicjs.ftl"/>

		<!-- inline scripts related to this page -->
		<script type="text/javascript">
            //列表-------------------------------------------------
			jQuery(function($) {
				// 右侧表格
				$('#MainGrid').datagrid({
					url: prefix + '/base/basedata/findBankBystatePage',
                    checkbox: true,
                    pagination: true,
					fitColumns:true,
					striped: true,
					singleSelect: true,
					loadMsg: "正在加载数据，请稍后...",
					columns:[[
                        { title: '账户id',field: 'bankid',width: 60},
                        { title: '账户编码',field: 'bankcode',width:60},
                        { title: '账号',field: 'accountcode',width:150},
                        { title: '账户名称',field: 'accountname',width: 150},
                        { title: '开户行名称',field: 'bankname',width:150},
                        { title: '联行行号',field: 'banklinenum',width:50},
                        { title: '区划编码',field: 'cantoncode',width: 100},
                        { title: '区划名称',field: 'cantonname',width:100}
					]],
					toolbar: '#toolbar',
                    onLoadSuccess: function (data) {
                        if (data.total == 0) {
                            $('#grid-main-data').find('.datagrid-body').html('<div style="text-align: center;font-size: 14px;padding: 20px 0;">查询无数据</div>');
                        }
                    }
				});

				$(window).resize(function() {
					$('#MainGrid').datagrid('resize');
				});
                $('#cantonid').combotree({
                    url:prefix+'/base/basedata/findAllCantonMap',
                    required: true,
                    width: 200
                });
			});
            //---区划三级下拉框
            function searchInfo() {
                $('#MainGrid').datagrid('load');
            }
            function sendInfo() {

                $( "#box-add" ).removeClass('hide').dialog({
                    title: '&nbsp;主动获取账户',
                    iconCls:'icon-add',
                    width: 600,
                    height: 400,
                    modal: true,
                    buttons:[{
                        text:'获取',
                        iconCls:'icon-ok',
                        width:80,
                        plain:false,
                        handler:function(){
                            saveInfo();
                        }
                    },{
                        text:'取消',
                        iconCls:'icon-cancel',
                        width:80,
                        plain:false,
                        handler:function(){$('#box-add').dialog('close')}
                    }]
                });
            }

            function bankManage(index){
                var row = $('#MainGrid').datagrid('getSelected');
                if (row == null) {
                    $.messager.alert('提示', "请选择数据", 'info');
                    return;
                }
                $('#form-update').form('load',row);
                $("#box-update").removeClass('hide').dialog({
                    title: '&nbsp;信息回执',
                    iconCls: 'icon-add',
                    width: 800,
                    height: 400,
                    modal: true,
                    buttons: [{
                        text: '保存',
                        iconCls: 'icon-ok',
                        width: 80,
                        plain: false,
                        handler: function () {
                            updateInfo();
                        }
                    }, {
                        text: '取消',
                        iconCls: 'icon-cancel',
                        width: 80,
                        plain: false,
                        handler: function () {
                            $('#box-update').dialog('close')
                        }
                    }]
                });
            }

            function updateInfo() {
                var url = prefix+'/base/basedata/returnBank';
                $('#form-update').form({
                    url: prefix + url,
                    onSubmit:function(){
                        var isValid = $(this).form('validate');
                        if (isValid){
                            $.messager.progress({
                                title: '提示',
                                msg: '数据处理中，请稍候……',
                                text: ''
                            });
                        }
                        return isValid;
                    },
                    success:function(data) {
                        $.messager.progress('close');
                        var data = eval('(' + data + ')');
                        if (data.success) {
                            searchInfo();
                            $('#box-update').dialog('close');
                        }
                        $.messager.alert('提示', data.msg, 'info');
                    }
                });
                $('#form-update').submit();
            }
            
            // 主动获取
            function saveInfo() {
                var cantonid = $('#cantonid').val();
                $('#form-add').form({
                    url: prefix +'/base/basedata/getbank',
                    onSubmit:function(param){
                        var isValid = $(this).form('validate');
                        if (isValid){
                            $.messager.progress({
                                title: '提示',
                                msg: '数据处理中，请稍候……',
                                text: ''
                            });
                        }
                        return isValid;
                    },
                    success:function(data) {
                        $.messager.progress('close');
                        var data = eval('(' + data + ')');
                        if(data.success) {
                            $('#box-add').dialog('close');
                            searchInfo();
                        }
                        $.messager.alert('提示', data.msg, 'info');
                    }
                });
                $('#form-add').submit();
            }

        </script>
	</body>
</html>
